package org.openkanban.client.ui.presenter;

import org.openkanban.client.login.LogIn;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.smartgwt.client.util.SC;

/**
 * Callback that handles die log out request
 */
public class LogOutRequestCallback implements RequestCallback {

    public void onError(Request request, Throwable exception) {
	SC.say("ERROR: " + exception.getMessage());
    }

    public void onResponseReceived(Request request, Response response) {
	if (response.getText().contains("success=true")) {
	    LogIn.setLogout();
	    LogIn.processLogOut();
	} else {
	    SC.say(response.getText());
	}
    }

}
